package com.example.demo.xcel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import static com.example.demo.xcel.EasyEcellMain.users1Map;

/**
 * @author FENGYU
 * @description
 * @date 2023/8/31 15:15
 */
// 编写监听器，继承 AnalysisEventListener 类并指定读取java对象
public class EasyExcelListener1 extends AnalysisEventListener<TUser1> {
    // 逐行读取 excel 信息
    public void invoke(TUser1 tUser1, AnalysisContext analysisContext) {

        if (tUser1.getXprojectCode() != null && !"".equals(tUser1.getXprojectCode())) {
            String key = tUser1.getXprojectCode()
                    + "_" + tUser1.getCode()
                    + "_" + tUser1.getUserCode()
                    + "_" + tUser1.getPeriodNum()
                    + "_" + tUser1.getReleasePercent()
                    + "_" + tUser1.getPlusPercent();

            if (users1Map.containsKey(key)) {
                System.out.println("key重复，" + key);
            }
            users1Map.put(key, tUser1);
        }


    }

    // excel 读取完毕触发
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("finsh");
    }
}

